home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / content / nsPropertyTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-08  |  5.8 KB  |  147 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * vim:cindent:ts=2:et:sw=2:
  3.  *
  4.  * ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is mozilla.org code.
  18.  *
  19.  * The Initial Developer of the Original Code is
  20.  * Netscape Communications Corporation.
  21.  * Portions created by the Initial Developer are Copyright (C) 1998
  22.  * the Initial Developer. All Rights Reserved.
  23.  *
  24.  * Contributor(s):
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  28.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK *****
  39.  *
  40.  * This Original Code has been modified by IBM Corporation. Modifications made by IBM 
  41.  * described herein are Copyright (c) International Business Machines Corporation, 2000.
  42.  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
  43.  *
  44.  * Date             Modified by     Description of modification
  45.  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
  46.  */
  47.  
  48. /**
  49.  * nsPropertyTable allows a set of arbitrary key/value pairs to be stored
  50.  * for any number of nodes, in a global hashtable rather than on the nodes
  51.  * themselves.  Nodes can be any type of object; the hashtable keys are
  52.  * nsIAtom pointers, and the values are void pointers.
  53.  */
  54.  
  55. #ifndef nsPropertyTable_h_
  56. #define nsPropertyTable_h_
  57.  
  58. #include "nscore.h"
  59.  
  60. class nsIAtom;
  61.  
  62. /**
  63.  * Callback type for property destructors.  |aObject| is the object
  64.  * the property is being removed for, |aPropertyName| is the property
  65.  * being removed, |aPropertyValue| is the value of the property, and |aData|
  66.  * is the opaque destructor data that was passed to SetProperty().
  67.  **/
  68. typedef void
  69. (*NSPropertyDtorFunc)(void           *aObject,
  70.                       nsIAtom        *aPropertyName,
  71.                       void           *aPropertyValue,
  72.                       void           *aData);
  73.  
  74. class nsPropertyTable
  75. {
  76.  public:
  77.   /**
  78.    * Get the value of the property |aPropertyName| for node |aObject|.
  79.    * |aResult|, if supplied, is filled in with a return status code.
  80.    **/
  81.   void* GetProperty(const void *aObject,
  82.                     nsIAtom    *aPropertyName,
  83.                     nsresult   *aResult = nsnull)
  84.   { return GetPropertyInternal(aObject, aPropertyName, PR_FALSE, aResult); }
  85.  
  86.   /**
  87.    * Set the value of the property |aPropertyName| to |aPropertyValue|
  88.    * for node |aObject|.  |aDtor| is a destructor for the property value
  89.    * to be called if the property is removed.  It can be null if no
  90.    * destructor is required.  |aDtorData| is an optional opaque context to
  91.    * be passed to the property destructor.  Note that the destructor is
  92.    * global for each property name regardless of node; it is an error
  93.    * to set a given property with a different destructor than was used before
  94.    * (this will return NS_ERROR_INVALID_ARG).
  95.    **/
  96.   NS_HIDDEN_(nsresult) SetProperty(const void         *aObject,
  97.                                    nsIAtom            *aPropertyName,
  98.                                    void               *aPropertyValue,
  99.                                    NSPropertyDtorFunc  aDtor,
  100.                                    void               *aDtorData);
  101.  
  102.   /**
  103.    * Delete the property |aPropertyName| for object |aObject|.
  104.    * The property's destructor function will be called.
  105.    **/
  106.   NS_HIDDEN_(nsresult) DeleteProperty(const void *aObject,
  107.                                       nsIAtom    *aPropertyName);
  108.  
  109.   /**
  110.    * Unset the property |aPropertyName| for object |aObject|, but do not
  111.    * call the property's destructor function.  The property value is returned.
  112.    **/
  113.   void* UnsetProperty(const void *aObject,
  114.                       nsIAtom    *aPropertyName,
  115.                       nsresult   *aStatus = nsnull)
  116.   { return GetPropertyInternal(aObject, aPropertyName, PR_TRUE, aStatus); }
  117.  
  118.   /**
  119.    * Deletes all of the properties for object |aObject|, calling the
  120.    * destructor function for each property.
  121.    **/
  122.   NS_HIDDEN_(void) DeleteAllPropertiesFor(const void *aObject);
  123.  
  124.   /**
  125.    * Deletes all of the properties for all objects in the property
  126.    * table, calling the destructor function for each property.
  127.    */
  128.   NS_HIDDEN_(void) DeleteAllProperties();
  129.   
  130.   ~nsPropertyTable() {
  131.     DeleteAllProperties();
  132.   }
  133.  
  134.   struct PropertyList;
  135.  
  136.  private:
  137.   NS_HIDDEN_(void) DestroyPropertyList();
  138.   NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom *aPropertyName) const;
  139.   NS_HIDDEN_(void*) GetPropertyInternal(const void *aObject,
  140.                                         nsIAtom    *aPropertyName,
  141.                                         PRBool      aRemove,
  142.                                         nsresult   *aStatus);
  143.  
  144.   PropertyList *mPropertyList;
  145. };
  146. #endif
  147.